<template>
    <div class="container" v-cloak>
        <div class="blurBg" :style="{background:'url('+blurBg+') 0 0 no-repeat'}"></div>
        <div class="dataInfo">
            <student-list ref="studentList" :classId="classId" :appCode="'APP_GROWTH_NOTE'" :radio="true"
                          :title="'成长手记'" :close="1"
                          @addStudent="addStudent" v-show="classId!==''"></student-list>
        </div>
    </div>
</template>
<script type="text/babel">
    import studentList from '../../../components/studentList.vue'
    export default{
        data(){
            return {
                studentId: this.$route.query.studentId ? this.$route.query.studentId : '',
                classId: this.$route.query.classId ? this.$route.query.classId : '',
                stuObj:''
            }
        },
        mounted(){
            this.$refs.studentList.showStudent();
            this.$util.jsBridgeCallBack('jsRightAction',this.closeWebView);
            this.$nextTick(function () {
                setTimeout(()=>{
                    this.$refs.studentList.studentList.map((e,i)=>{
                        if(e.studentId==this.studentId){
                            this.$set(this.$refs.studentList.studentList[i],'checked',true)
                        }
                    })
                    this.propsTitle();
                },300);
                document.documentElement.scrollTop=1;
                document.body.scrollTop=1;
            })
        },
        components: {
            studentList
        },
        methods: {
            propsTitle(){
                this.$util.JsBridge('propsTitle', {
                    title: '选择学员',
                    titleRight:'确定',
                }, (res) => {
                })
            },
            closeWebView(){
                if(this.stuObj!==''){
                    this.$util.JsBridge('chooseStudent', {
                        studentObj:this.stuObj
                    }, (res) => {})
                }
                this.$util.JsBridge('closeWebView', {}, () => {})
            },
            addStudent(saveList){
                if (saveList && saveList.length > 0) {
                    saveList.forEach((el, index) => {
                        if (el.checked) {
                            this.studentId = el.studentId;
                            this.stuObj=JSON.stringify(el)
                        }
                    });
                }
            },
        }
    }
</script>
<style scoped lang="scss">
    .container {
        width: 100%;
        height: 100%;
        background: #000;
        position: relative;
    }
</style>
